/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.inspur.edp.web.frontendproject.debuguri;

import com.inspur.edp.lcm.metadata.api.entity.GspProject;
import com.inspur.edp.lcm.metadata.api.entity.MetadataProject;
import com.inspur.edp.web.common.entity.TerminalType;
import com.inspur.edp.web.common.metadata.GspProjectUtility;
import com.inspur.edp.web.common.metadata.MetadataUtility;

/**
 * description: 表单调试Url地址
 *
 * @author Noah Guo
 * @date 2021/03/17
 */
public class FormMetadataDebugUriWithPC extends AbstractFormMetadataDebugUri {
    public FormMetadataDebugUriWithPC() {
        super(TerminalType.PC);
    }

    @Override
    public String getFormMetadataDebugUri(String formMetadataRelativePath, String formMetadataId) {
        // 1. 获取表单元数据对应route Uri
        String routeUri = getFormMetadataRouteUri(formMetadataRelativePath, formMetadataId);

        // 2. 获取部署路径
        MetadataProject metadataProject = MetadataUtility.getInstance().getMetadataProject(formMetadataRelativePath);
        GspProject gspProject = GspProjectUtility.getProjectInformation(metadataProject.getProjectPath());
        String deploymentPath = "/" + gspProject.getSuDeploymentPath().toLowerCase();

        String projectName = GspProjectUtility.getProjectName(gspProject);

        return deploymentPath + "/" + TerminalType.PC.getPublishPathName() + "/" + projectName + "/" + "index.html" + "#" + routeUri;
    }


}
